<?php 
	//计算当月到今天22点个时间段的人流量
	
	//设置时区
	ini_set('date.timezone','Asia/Shanghai');
    $conn = new mysqli("localhost:3306","root","lc971019");
	if($conn->connect_error)
	{
		die('Could not connect:'.$conn->connect_error());
	}
	
	//本月1日8点开始算
	echo $time_start = date("Y-m",intval(time()))."-01 08:00:00";
	//到今天22点之间
	$time_end = date("Y-m-d",intval(time()))." 22:00:00";
	
	//相当于1日22点
	$time_tmp = strtotime($time_start)+3600*14;
	
	$i=0;
	
	while($time_tmp<strtotime($time_end)){
		$sql = "select count(distinct mac) from wifidata where times > ".time_start." and times <= ".date("Y-m-d H:i:s",$time_tmp).";";
		$time_start = date("Y-m-d H:i:s",strtotime($time_start)+3600*24);
		
		//每次加24小时
		$time_tmp = $time_tmp+3600*24;
		
		$result_fp_thismonth[$i] = $conn->query($sql);
		
		$i = $i+1;
		
		
		}
	$sql = "select count(distinct mac) from wifidata where times > ".time_start." and times <= ".time_end.";";
	
	$result_fp_thismonth[$i] = $conn->query($sql);
	$j=0;
	while($j<$i){
		if($result_fp_thismonth[$j]->num_rows > 0){
			while($row = $result_fp_thismonth[$j]->fetch_assoc()){
				$fp_thismonth_count[$j]=$row["count(distinct mac)"];//各时间段的人数，以天为单位
				}
			}
		$j=$j+1;
		}
?>